using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace InsertVideoForHostedWordpress
{
    public partial class frmMain : Form
    {
        string link = "";
        string codetxt = "";
        bool title = true;

        public frmMain()
        {
            InitializeComponent();
        }

        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (txbxLink.Text == "")
                MessageBox.Show("Sorry, you haven't put a link in.", "Big Fat Hairy Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
            {
                if (txbxLink.Text.StartsWith("http://video.google") ||
                    txbxLink.Text.StartsWith("http://www.video.google"))
                {
                    link = txbxLink.Text;
                    title = chbxTitle.Checked;
                    codetxt = "GoogleVideo";
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else if (txbxLink.Text.StartsWith("http://youtube.com") ||
                    txbxLink.Text.StartsWith("http://www.youtube.com"))
                {
                    link = txbxLink.Text;
                    title = chbxTitle.Checked;
                    codetxt = "YouTube";
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else if (txbxLink.Text.StartsWith("http://www.dailymotion")){
                    link = txbxLink.Text.Substring(31);
                    title = false;
                    codetxt = "dailymotion id";
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                    MessageBox.Show("Sorry, this isn't a valid link", "Big Fat Hairy Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        public string VideoLink
        {
            get { return link; }
        }

        public bool IncludeTitle
        {
            get { return title; }
        }

        public string VideoType
        {
            get { return codetxt; }
        }
    }
}